package com.treasure.service.sms.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.dto.PrepareResult;
import com.treasure.service.enums.PayEnum;
import com.treasure.service.result.ResponseResult;
import com.treasure.service.sms.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* @Description:    客户消息推送(短信)
* @Author:         panxinwen
* @CreateDate:     2018/11/18 14:10
* @Version:        1.0
*/
@Api(value = "短信发送",description = "短信发送，包括单条发送及群发")
@RestController
@RequestMapping("/sms/v1")
public class SmsController {

    @Autowired
    private SmsService smsService;

    @LogInfo(log="短信发送",isPrint = true)
    @ApiOperation(value = "短信发送",notes = "短信发送)")
    @PostMapping("/sendSms")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "smsType", value = "短信类型",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "phonenumber", value = "手机号",required = true,dataType = "String",paramType = "query"),
    })
    public ResponseEntity<ResponseResult> sendSms(
            @RequestParam(value = "smsType", required = true) Integer smsType,
            @RequestParam(value = "phonenumber", required = true) String phonenumber
    ) throws Exception {
        ResponseResult responseResult = smsService.sendSms(smsType,phonenumber);
        return  ResponseEntity.ok(responseResult);

    }
    @LogInfo(log="短信发送",isPrint = true)
    @ApiOperation(value = "短信发送",notes = "短信发送)")
    @PostMapping("/sendSmsTemp")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "temp", value = "短信模板",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "phonenumber", value = "手机号",required = true,dataType = "String",paramType = "query"),
    })
    public ResponseEntity<ResponseResult> sendSmsTemp(
            @RequestParam(value = "temp", required = true) String temp,
            @RequestParam(value = "phonenumber", required = true) String phonenumber
    ) throws Exception {
        ResponseResult responseResult = smsService.sendSmsTemp(temp,phonenumber);
        return  ResponseEntity.ok(responseResult);

    }

}
